/**
 * Created by aresn on 16/6/20.
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './views/app.vue';
import Frame from './views/frame.vue';
import Routers from './router';
import Env from './config/env';
import iView from 'iview';
import 'iview/dist/styles/iview.css';
import VueResource from 'vue-resource';

import Store from './store/store.js';

import Login from './views/login.vue';

Vue.use(VueRouter);
Vue.use(VueResource);
Vue.use(iView);

// 开启debug模式
Vue.config.debug = true;
Vue.prototype.store=Store;

// 路由配置
let router = new VueRouter({
    // 是否开启History模式的路由,默认开发环境开启,生产环境不开启。如果生产环境的服务端没有进行相关配置,请慎用
    history: Env != 'production'
});

router.map(Routers);

router.beforeEach((transition) => {
	// if(!Store.state.logined){
	// 	router.go({
	// 		path:'/login'
	// 	});
	// }
	transition.next();
    window.scrollTo(0, 0);
});

router.afterEach(() => {

});

router.redirect({
    '*': "/login"
});

router.start(Frame, '#app');

// if(!Store.state.logined){
// 	router.go({
// 		path:'/login'
// 	});
// }
Vue.prototype.myRouter=router;
Vue.prototype.path="http://192.168.0.104:8083/merchant/";
Vue.prototype.publicPath="http://192.168.20.111:8080";
Vue.filter('toRMB',function(value){
	return "￥"+value
})

